<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>

<body class="gray-bg">

<div class="container-div ui-layout-center">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="upload-form">
                <div class="select-list">
                    <ul>
<!--                        <li>-->
<!--                            上传人工号：<input type="text" name="importUserid"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            上传文件名：<input type="text" name="fileName"/>-->
<!--                        </li>-->
                        <li>
                            上传人工号：
                            <input class="importUserid" type="text" name="importUserid" style="width: 100px" />
                        </li>
                        <li>
                            上传文件名：
                            <input class="fileName" type="text" name="fileName" style="width: 100px"/>
                        </li>
                        <li class="select-time">
                            <label>上传时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-success  btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-success  btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
            <a class="btn btn-success" onclick="upload()" shiro:hasPermission="worktime:upload:add">
                <i class="fa fa-plus"></i> 新增
            </a>
<!--            $.table.exportExcel() shiro:hasPermission="system:student:export"-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()"><i class="fa fa-download"></i> 导出</a>
<!--            //映射路径-->
<!--            exportUrl: prefix + "/export",-->

        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
    var downFlag = [[${@permission.hasPermi('staff:upload:download')}]];
    var datas = [[${@dict.getType('input_record_status')}]];
    var prefix = ctx + "staff/list/upload";

    $(function () {
        $('body').layout({west__size: 185});
        queryRecordList();
    });

    function queryRecordList() {
        var options = {
            //url: prefix + "/list",
            url: '/staff/upload/list',
            createUrl: prefix + "/add",
            downloadUrl: '/staff/upload/download',
            exportUrl: '/staff/upload/export',
            sortName: "uploadTime",
            sortOrder: "desc",
            modalName: "数据录入",
            //exportUrl: prefix+"/export",
            //importTemplateUrl:prefix+"/importTemplate",
            search: false,
            showExport: false,
            columns: [
                {
                    field: 'importId',
                    title: '记录ID',
                    visible: false
                },
                {
                    field: 'importUserid',
                    title: '工号',
                    sortable: true
                },
                {
                    field: 'userName',
                    title: '上传用户名'
                },
                {
                    field: 'uploadTime',
                    title: '上传时间',
                    sortable: true
                },
                {
                    field: 'fileName',
                    title: '上传文件名'
                },
                {
                    field: 'parseStatus',
                    title: '状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'errorPath',
                    title: '错误信息',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + downFlag + '" href="#" onclick="$.operate.download(\'' + row.importId + '\')"><i class="fa fa-edit"></i>下载</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    }

    function upload() {
        var url = '/staff/upload/add';

        var width = 800;
        var height = ($(window).height() - 50);
        layer.open({
            type: 2,
            area: [width + 'px', height + 'px'],
            fix: false,
            //不固定
            maxmin: true,
            shade: 0.3,
            title: "添加员工数据",
            content: url,
            btn: ['确定'],
            // 弹层外区域关闭
            shadeClose: true,
            yes: function (index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler();
            },
            cancel: function (index) {
                return true;
            }
        });
    }

    function dow() {
        $.ajax({
            type: "GET", url: "upload/downlod", data: {}, success: function (result) {
                if (result.status == 0) {
                    window.open(result.data)
                }
                if (result.message != null) {
                    layer.msg(result.message)
                }
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.msg('{"status":"' + XMLHttpRequest.status + '","readyState":"' + XMLHttpRequest.readyState + '","textStatus":"' + textStatus + '","errorThrown":"' + errorThrown + '"}')
            }
        })
    }
</script>
</body>
</html>